def insertSort(sequence):
    """
    :param sequence:
    :return:
    """
    length = len(sequence)  #5
    for i in range(1,length): #1,2,3,4
        j = i #1
        while j > 0:
            if sequence[i] < sequence[j-1]:
                j -= 1 #0
            else:
                break
        temp = sequence[i] #1
        for l in range(i,j,-1): #1
            sequence[l] = sequence[l-1]
        sequence[j] = temp
    return sequence

list1 = [2,2,2,2,2,2,3,3,3,5,7,3,55,99,655,343,7,8,2] #[1,2,7,9,6]
print(insertSort(list1))